//
// Created by QU on 2023/8/16.
//

#ifndef VHDLSENDER_UTILS_H
#define VHDLSENDER_UTILS_H

#include "header.h"
#include <stdio.h>
#include <stdbool.h>

extern bool VERBOSE_FLAG;

// ---------- logger ------------
void printErrorMessage(const char *errorMessage);

void printErrorMessageWithExtraMessage(const char *error, const char *errorMessage);

void printWarningMessage(const char *warningMessage);

void printWarningMessageWithExtraMessage(const char *warning, const char *warningMessage);

void printInfoMessage(const char *infoMessage);

void printInfoMessageWithExtraMessage(const char *info, const char *infoMessage);

void printDebugMessage(const char *debugMessage);

void printDebugMessageWithExtraMessage(const char *debug, const char *debugMessage);

// ---------- getter ------------
size_t getFrameNumOneLineFromBufferLength(size_t bufferLength, enum VC_TYPE vcType, uint16_t splitedCols);

size_t getFrameNumOneLineFromOneLineLength(enum VC_TYPE vcType, size_t oneLineLength);

size_t getTotalFrameNumFromBufferLength(size_t bufferLength, enum VC_TYPE vcType, uint16_t splitedCols);

size_t getTotalFullLengthFormBufferLength(size_t bufferLength, enum VC_TYPE vcType, uint16_t splitedCols);

size_t getTotalFullLengthOneLineFromBufferLength(size_t bufferLength, enum VC_TYPE vcType, uint16_t splitedCols);

size_t getBufferLengthFromGenFrameNum(size_t genTotalFrameNum, enum VC_TYPE vcType);

size_t getBodyLengthFormVCType(enum VC_TYPE vcType);

size_t getLoadLengthFromVCType(enum VC_TYPE vcType);

//////////////////////////////////////////////////////////////////////////////////////////////////////

// ---------- convertor ------------
enum VC_TYPE vcTypeConvertor(uint16_t vcTypeInt);


// ---------- buffer printer ------------
void printVCTypeHeader(const vcTypeHeader_t *header);

void printBufferDataContent(uint8_t *mallocBuffer, size_t bufferSize);

void printBufferDataContentLast20Bytes(uint8_t *mallocBuffer, size_t bufferSize);

void printOutputBufferContent(enum VC_TYPE vcType, uint16_t splitedCols, size_t bufferOneLineLength,
                              uint8_t outBuffer[splitedCols][bufferOneLineLength]);

//////////////////////////////////////////////////////////////////////////////////////////////////////

void testUtils();


#endif //VHDLSENDER_UTILS_H
